﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Util.Domains;
using Util.Domains.Auditing;

namespace IterationLife.Domains.Sports.Models {
    /// <summary>
    /// 体育比赛
    /// </summary>
    [Description( "体育比赛" )]
    public partial class SportEvent : AggregateRoot<SportEvent>,IDelete,IAudited {
        /// <summary>
        /// 初始化体育比赛
        /// </summary>
        public SportEvent() : this( Guid.Empty ) {
        }

        /// <summary>
        /// 初始化体育比赛
        /// </summary>
        /// <param name="id">体育比赛标识</param>
        public SportEvent( Guid id ) : base( id ) {
            SportEventGroups = new List<SportEventGroup>();
        }

        /// <summary>
        /// 合作放比赛Id
        /// </summary>
        [StringLength( 200, ErrorMessage = "合作放比赛Id输入过长，不能超过200位" )]
        public string PartnerEventId { get; set; }
        /// <summary>
        /// 比赛类型
        /// </summary>
        [Required(ErrorMessage = "比赛类型不能为空")]
        public int EventType { get; set; }
        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime? StartTime { get; set; }
        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime? EndTime { get; set; }
        /// <summary>
        /// 天气
        /// </summary>
        [StringLength( 20, ErrorMessage = "天气输入过长，不能超过20位" )]
        public string Weather { get; set; }
        /// <summary>
        /// 湿度
        /// </summary>
        [StringLength( 20, ErrorMessage = "湿度输入过长，不能超过20位" )]
        public string Humidity { get; set; }
        /// <summary>
        /// 温度
        /// </summary>
        [StringLength( 20, ErrorMessage = "温度输入过长，不能超过20位" )]
        public string Temperature { get; set; }
        /// <summary>
        /// 场地类型
        /// </summary>
        [StringLength( 20, ErrorMessage = "场地类型输入过长，不能超过20位" )]
        public string GrassType { get; set; }
        /// <summary>
        /// 人数
        /// </summary>
        [Required(ErrorMessage = "人数不能为空")]
        public int PersonCnt { get; set; }
        /// <summary>
        /// 定位
        /// </summary>
        [StringLength( 500, ErrorMessage = "定位输入过长，不能超过500位" )]
        public string FieldPlace { get; set; }
        /// <summary>
        /// 球场名称
        /// </summary>
        [StringLength( 500, ErrorMessage = "球场名称输入过长，不能超过500位" )]
        public string FieldName { get; set; }
        /// <summary>
        /// 全场数据
        /// </summary>
        public string JsonData { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreationTime { get; set; }
        /// <summary>
        /// 创建人
        /// </summary>
        public Guid? CreatorId { get; set; }
        /// <summary>
        /// 最后修改时间
        /// </summary>
        public DateTime? LastModificationTime { get; set; }
        /// <summary>
        /// 最后修改人
        /// </summary>
        public Guid? LastModifierId { get; set; }
        /// <summary>
        /// 是否删除
        /// </summary>
        [Required(ErrorMessage = "是否删除不能为空")]
        public bool IsDeleted { get; set; }
        
        /// <summary>
        /// 体育比赛分组列表
        /// </summary>
        public virtual ICollection<SportEventGroup> SportEventGroups { get; set; }
        
        /// <summary>
        /// 添加描述
        /// </summary>
        protected override void AddDescriptions() {
            AddDescription( "体育比赛编号", Id );
            AddDescription( "合作放比赛Id", PartnerEventId );
            AddDescription( "比赛类型", EventType );
            AddDescription( "开始时间", StartTime );
            AddDescription( "结束时间", EndTime );
            AddDescription( "天气", Weather );
            AddDescription( "湿度", Humidity );
            AddDescription( "温度", Temperature );
            AddDescription( "场地类型", GrassType );
            AddDescription( "人数", PersonCnt );
            AddDescription( "定位", FieldPlace );
            AddDescription( "球场名称", FieldName );
            AddDescription( "全场数据", JsonData );
            AddDescription( "创建时间", CreationTime );
            AddDescription( "创建人", CreatorId );
            AddDescription( "最后修改时间", LastModificationTime );
            AddDescription( "最后修改人", LastModifierId );
        }
        
        /// <summary>
        /// 添加变更列表
        /// </summary>
        protected override void AddChanges( SportEvent newEntity ) {
            AddChange( "Id", "体育比赛编号", Id, newEntity.Id );            
            AddChange( "PartnerEventId", "合作放比赛Id", PartnerEventId, newEntity.PartnerEventId );
            AddChange( "EventType", "比赛类型", EventType, newEntity.EventType );
            AddChange( "StartTime", "开始时间", StartTime, newEntity.StartTime );
            AddChange( "EndTime", "结束时间", EndTime, newEntity.EndTime );
            AddChange( "Weather", "天气", Weather, newEntity.Weather );
            AddChange( "Humidity", "湿度", Humidity, newEntity.Humidity );
            AddChange( "Temperature", "温度", Temperature, newEntity.Temperature );
            AddChange( "GrassType", "场地类型", GrassType, newEntity.GrassType );
            AddChange( "PersonCnt", "人数", PersonCnt, newEntity.PersonCnt );
            AddChange( "FieldPlace", "定位", FieldPlace, newEntity.FieldPlace );
            AddChange( "FieldName", "球场名称", FieldName, newEntity.FieldName );
            AddChange( "JsonData", "全场数据", JsonData, newEntity.JsonData );
            AddChange( "CreationTime", "创建时间", CreationTime, newEntity.CreationTime );
            AddChange( "CreatorId", "创建人", CreatorId, newEntity.CreatorId );
            AddChange( "LastModificationTime", "最后修改时间", LastModificationTime, newEntity.LastModificationTime );
            AddChange( "LastModifierId", "最后修改人", LastModifierId, newEntity.LastModifierId );
        }
    }
}